package com.jifeng.api.crud.controller;

import com.jifeng.api.annotation.AccessLimitAnnotation;
import com.jifeng.api.crud.entity.DeviceinfoEntity;
import com.jifeng.api.crud.service.DeviceinfoService;
import com.jifeng.api.utils.PageUtils;
import com.jifeng.api.utils.R;
import com.jifeng.api.vo.ReqRentVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Arrays;
import java.util.Map;


/**
 * 
 *
 * @author jifeng
 * @email 1593140625@qq.com
 * @date 2020-09-05 09:24:04
 */
@RestController
@RequestMapping("crud/deviceinfo")
public class DeviceinfoController {
    @Autowired
    private DeviceinfoService deviceinfoService;

    /**
     * 入库
     */
    @PostMapping("/add")
    public R add(@RequestBody DeviceinfoEntity deviceinfo){
       R rs= deviceinfoService.add(deviceinfo);
        return rs;
    }

    /**
     * 更新入库的数据
     */
    @PostMapping("/myUpdate")
    public R myUpdate(@RequestBody DeviceinfoEntity deviceinfo){
        R rs= deviceinfoService.myUpdate(deviceinfo);
        return rs;
    }

    /**
     * 列表
     */
    @GetMapping("/list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = deviceinfoService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @GetMapping("/info/{id}")
    public R info(@PathVariable("id") Long id){
		DeviceinfoEntity deviceinfo = deviceinfoService.getById(id);

        return R.ok().put("deviceinfo", deviceinfo);
    }

    /**
     * 保存
     */
    @PostMapping("/save")
    public R save(@RequestBody DeviceinfoEntity deviceinfo){
		deviceinfoService.save(deviceinfo);

        return R.ok();
    }

    /**
     * 修改
     */
    @PostMapping("/update")
    public R update(@RequestBody DeviceinfoEntity deviceinfo){
		deviceinfoService.updateById(deviceinfo);

        return R.ok();
    }

    /**
     * 删除
     */
    @PostMapping("/delete")
    public R delete(@RequestBody Long[] ids){
		deviceinfoService.removeByIds(Arrays.asList(ids));

        return R.ok();
    }

}
